home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / openmath.rep / code.ys < prev   
Encoding:
Text File  |  2002-03-13  |  3.7 KB  |  128 lines

  1.  
  2.  
  3. 10 # OMForm(_expression)
  4. //     <-- "<OMOBJ>" : OMFormExpression(expression) : "</OMOBJ>";
  5.      <--
  6.      [
  7.      omindent := 0;
  8.      OMEcho("<OMOBJ>");
  9.      OMIndent();
  10.      OMFormExpression(expression);
  11.      OMUndent();
  12.      OMEcho("</OMOBJ>");
  13.      ];
  14.  
  15. 10 # OMFormExpression(i_IsString)  <-- OMEcho(i);
  16. 11 # OMFormExpression(i_IsInteger) <-- OMEcho("<OMI>":String(i):"</OMI>");
  17. 12 # OMFormExpression(i_IsNumber)  <-- OMEcho("<OMF dec=\"":String(i):"\"/>");
  18. 13 # OMFormExpression(i_IsConstant)_(OMSymbol[ String(i) ] != Empty)
  19.      <--
  20.      [
  21.      OMEcho("<OMS cd=\"":OMSymbol[ String(i) ][1]:"\" name=\"":OMSymbol[ String(i) ][2]:"\"/>");
  22.      ];
  23. 14 # OMFormExpression(i_IsConstant)
  24.      <--
  25.      [
  26.      OMEcho("<OMS cd=\"yacas\" name=\"":String(i):"\"/>");
  27.      ];
  28. 15 # OMFormExpression(i_IsVariable)_(OMSymbol[ String(i) ] != Empty)
  29.      <--
  30.      [
  31.      OMEcho("<OMS cd=\"":OMSymbol[ String(i) ][1]:"\" name=\"":OMSymbol[ String(i) ][2]:"\"/>");
  32.      ];
  33. 16 # OMFormExpression(i_IsVariable)<-- OMEcho("<OMV name=\"":String(i):"\"/>");
  34.  
  35. 10 # OMFormExpression(function_IsFunction)
  36.      <--
  37.      [
  38.      OMEcho("<OMA>");
  39.      OMIndent();
  40.      OMFormFunction(function);
  41.      OMUndent();
  42.      OMEcho("</OMA>");
  43.      ];
  44. 10 # OMFormFunction(_function)_(OMSymbol[ Type(function) ] != Empty)
  45.      <--
  46.      [
  47.      OMEcho("<OMS cd=\"":OMSymbol[ Type(function) ][1]:"\" name=\"":OMSymbol[ Type(function) ][2]:"\"/>");
  48.      If(OMSymbol[ Type(function) ][3] = {},
  49.         [ ForEach(arg, function) OMFormExpression(arg);
  50.         ],
  51.         [ arity := Length(function);
  52.           ForEach(i, OMSymbol[ Type(function) ][3])
  53.             [
  54.              If(IsNumber(i),
  55.                 If(i <= arity,  OMFormExpression(function[i]) ),
  56.                 If(IsString(i), OMFormExpression(i)           )
  57.                 );
  58.             ];
  59.         ]
  60.         );
  61.      ];
  62. 11 # OMFormFunction(_function)
  63.      <--
  64.      [
  65.      OMEcho("<OMS cd=\"yacas\" name=\"":Type(function):"\"/>");
  66.      ForEach(arg, function) OMFormExpression(arg);
  67.      ];
  68.  
  69. omindent := 0;
  70. OMIndentSpace() :=
  71. [
  72.   Space(omindent);
  73. ];
  74.  
  75. OMEcho(_expression) <--
  76. [
  77.   OMIndentSpace();
  78.   Echo({expression});
  79. ];
  80. OMIndent() := [omindent := omindent + 2;];
  81. OMUndent() := [omindent := omindent - 2;];
  82.  
  83.  
  84. HoldArgNr("OMForm",1,1);
  85. //HoldArgNr("OMFormExpression",1,1);
  86. //HoldArgNr("OMFormFunction",1,1);
  87.  
  88.  
  89. OMSymbol :=
  90. {
  91.   // [20010916 AGP] I couldn't find these symbols in the def files:
  92.   //{ "E",         { "nums1", "e",        {} } },
  93.   //{ "Gamma",     { "nums1", "gamma",    {} } },
  94.   { "Infinity",  { "nums1", "infinity",   {} } },
  95.   { "Undefined", { "nums1", "NaN",        {} } },
  96.   { "Pi",        { "nums1", "pi",         {} } },
  97.   // [20010916 AGP] From stdopers.ys:
  98.   { "And"   , { "logic1", "and",        {} } },
  99.   { "=="    , { "logic1", "equivalent", {} } },
  100.   { "!=="   , { "logic1", "not",
  101.                 { "<OMA><OMS cd=\"logic1\" name=\"equivalent\"/>",
  102.                   1,
  103.                   2,
  104.                   "</OMA>"
  105.                 }
  106.               }                              },
  107.   { "False" , { "logic1", "false",      {} } },
  108.   { "Or"    , { "logic1", "or",         {} } },
  109.   { "True"  , { "logic1", "true",       {} } },
  110.   //{ "Xor"   , { "logic1", "xor",        {} } },//[20010916 AGP ] Not in Yacas
  111.   { "&" , { "yacas", "bitwise_and", {} } },
  112.   { "|" , { "yacas", "bitwise_or",  {} } },
  113.   { "%" , { "yacas", "bitwise_xor", {} } },
  114.   { "/" , { "arith1", "divide", {} } },
  115.   { "-" , { "arith1", "minus",  {} } },
  116.   { "+" , { "arith1", "plus",   {} } },
  117.   { "^" , { "arith1", "power",  {} } },
  118.   { "*" , { "arith1", "times",  {} } },
  119.   { "+" , { "arith1", "plus",   {} } },
  120.   { "", { "error", "unexpected_symbol", {} } }
  121. };
  122.  
  123. Load("constants.rep/om.ys");
  124. Load("stdfuncs.rep/om.ys");
  125. Load("stubs.rep/om.ys");
  126. Load("logic.rep/om.ys");
  127. Load("complex.rep/om.ys");
  128.